#-*- codeing = utf-8 -*-
#@Time : 2021/2/20 19:07
#@Author : 李佳恒
#@File : testBs4.py
#@Software: PyCharm


'''
BeautifulSoup4将复杂HTML文档转换成复杂树形结构 每个节点都是python对象 可以分为四个

- Tag
- NavigableString
- BeautifulSoup
- Comment
'''

from bs4 import BeautifulSoup

file = open("./index.html","rb")
html = file.read()
bs =BeautifulSoup(html,"html.parser")
# print(bs.title)
# t_list = bs.find_all("i")
import re
#正则表达式搜索 使用search()方法匹配内容

# def name_is_exists(tag):
#     return tag.has_attr("name")
# t_list = bs.find_all(name_is_exists)
# t_list = bs.find_all(class_="namebox")
# t_list = bs.find_all(text= "谢霆锋")
t_list = bs.select(".namebox")
print(t_list)



